<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="请输入1-100之间的整数" v-model="num">
    <input type="button" value="猜一猜" @click="f()">
    <h1>结果:{{result}}</h1>
</div>
<script src="js/vue.js"></script>
<script>
    //生成1-100随机整数
    let x = parseInt(Math.random()*100)+1;
    console.log(x);
    Vue.createApp({
        data() {
            return {
                num:"",result:""
            }
        },
        methods: {
            f() {
                if (this.num>x){
                    this.result="猜大了!";
                }else if(this.num<x){
                    this.result="猜小了!";
                }else{
                    this.result="恭喜你猜对了!";
                }
            }
        },
    }).mount("body>div");
</script>
</body>
</html>